package com.newland.starpos.partner.listen;

import com.newland.starpos.partner.bean.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * Created by liuNW on 2018/9/30.
 */
@Component
public class EventPublish {

    @Autowired
    private ApplicationContext applicationContext;

    private void publishEvent(ApplicationContextEvent event){
        applicationContext.publishEvent(event);
    }

    @Async(value = "asyncExecutor")
    public void publishUserRegister(User newUser) {
        this.publishEvent(new UserRegisterEvent(applicationContext, newUser));
    }
}
